package com.zitronella.course.osseventmanager.mvc;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;

import javax.servlet.http.HttpSession;

import com.zitronella.course.osseventmanager.service.PositionService;

@Controller
@RequestMapping("/positions")
public class PositionListController{

    private PositionService positionService;

       @Autowired
       public void setPositionService(PositionService positionService) {
           this.positionService = positionService;
       }
    

    @RequestMapping(method = RequestMethod.GET)
    public String preparePositionList(Model model, HttpSession session) {
        model.addAttribute("positions", positionService.findAllPositions());
        return "positions";
    }
}